#include <stdio.h>
#include <stdlib.h>

int *delete(int num,int n,int *a)
{
int i,p,j;
int *f;
f=a;
f=realloc(f,n-1*sizeof(*f));
for (i=0;i<n;i++)
{
if (a[i]==num)
{
p=i;
break;
}
}
if (p==0){
for (j=0;j<n-1;j++)
f[j]=a[j+1];}
else
{
for (j=0;j<i;j++)
{
f[j]=a[j];
}
for (j=i;j<n-2;j++)
{
f[j]=a[j+1];
}
}
return f;
}
//comment

append(int s,int n,int *a)
{
int i,e;
a=realloc(a,n+s*sizeof(*a));
for (i=n;i<n+s;i++)
{
printf ("Enter an element:");
scanf ("%d",&e);
a[i]=e;
}
}


void main()
{
int s,i,n,v;
printf ("Enter the no. of elements in the list.");
scanf ("%d",&n);
int *a;
a=malloc(n*sizeof(*a));
for (i=0;i<n;i++)
{
printf ("Enter a no.:");
scanf ("%d",&a[i]);
}
for (i=0;i<n;i++){
printf ("%d ",a[i]);}

printf("Enter the no. of elements to be added in the list:");
scanf ("%d",&s);

append(s,n,a);
n=s+n;
for (i=0;i<n;i++)
{printf ("%d",a[i]);}

printf ("No.to be deleted:");
scanf ("%d",&v);
a=delete(v,n,a);

for (i=0;i<n;i++)
{printf ("%d",a[i]);}

}


